<%@ Page Title="Member_Certified Item" Language="C#" AutoEventWireup="true" CodeBehind="Member_CertifiedItem.aspx.cs" Inherits="Youz.CreditRepay.Manage.Member_CertifiedItem" %>

<%@ Register Src="~/Controls/_AuditStateControl.ascx" TagPrefix="uc1" TagName="_AuditStateControl" %>


<script>


    var requireJS = [
        //"assets/js/jquery.form.js"
    ];
    loadJS(requireJS);
</script>
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h2><i class="fa fa-edit"></i>身份认证</h2>
            </div>
            <div class="panel-body">
                <form id="frm" class="form-horizontal" method="post" enctype="multipart/form-data">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Certified, "MemberAccount", "会员帐号") %></label>
                                <div class="col-md-9">
                                    <input type="text" id="MemberAccount" name="MemberAccount" maxlength="50" class="form-control" readonly="readonly" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label">姓名</label>
                                <div class="col-md-9">
                                    <input type="text" id="Name" name="Name" maxlength="50" class="form-control" readonly="readonly" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label">身份证号</label>
                                <div class="col-md-9">
                                    <input type="text" id="CredentialsNum" name="CredentialsNum" maxlength="50" class="form-control" readonly="readonly" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label">身份证照片</label>
                                <div class="col-md-9">
                                    <img id="Photo1" class="img-thumbnail col-sm-2" src="/assets/img/DefaultImg.jpg" alt="身份证正面照" />
                                    <img id="Photo2" class="img-thumbnail col-sm-2" src="/assets/img/DefaultImg.jpg" alt="身份证反面照" />
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Certified, "CreateTime", "创建时间") %></label>
                                <div class="col-md-9">
                                    <input type="text" id="CreateTime" name="CreateTime" maxlength="20" class="form-control" readonly="readonly" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Certified, "Status", "状态") %></label>
                                <div class="col-md-9">
                                    <uc1:_AuditStateControl runat="server" ID="_AuditStateControl" />
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label" for="RoleDesc"><%: R(LanguageModule.Member_Certified, "AuditOpinion", "审核意见") %></label>
                                <div class="col-md-9">
                                    <textarea id="AuditOpinion" name="AuditOpinion" rows="2" maxlength="1000" class="form-control"></textarea>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Certified, "AuditTime", "审核时间") %></label>
                                <div class="col-md-9">
                                    <input type="text" id="AuditTime" name="AuditTime" maxlength="100" class="form-control" readonly="readonly" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="alert alert-danger" style="display: none;">
                        <button type="button" class="close" data-dismiss="alert">×</button><strong>提示信息：</strong><span class="content"></span>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <label class="col-md-3 control-label"></label>
                            <div class="form-actions">
                                <div class="col-md-9">
                                    <button class="btn btn-primary" type="button" id="Processing" name="Processing"><%: R(LanguageModule.M_Common, "Review", "审核中") %></button>
                                    <button class="btn btn-success" type="button" id="AuditNotPass" name="AuditNotPass"><%: R(LanguageModule.M_Common, "AuditNotPass", "拒 絕") %></button>
                                    <button class="btn btn-success" type="button" id="AuditBy" name="AuditBy"><%: R(LanguageModule.M_Common, "AuditBy", "同 意") %></button>
                                    <button class="btn btn-default" type="button" id="btnCancel"><%: R(LanguageModule.M_Common, "btnCancel", "取消") %></button>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="modalImg">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">身份证照片</h4>
            </div>
            <div class="modal-body">
                <img id="img" class="img-responsive" src="" />
            </div>
            <div class="modal-footer">
                <button data-dismiss="modal" class="btn btn-default" type="button">取消</button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

    var flag = false;

    //function validate() {
    //    return $("#frm").valid();
    //};

    function get() {
        var CertifiedID = "<%: WebHelper.Get("CertifiedID") %>";

        $("#AuditOpinion").prop("disabled", true);
        $("#Processing").hide();
        $("#AuditNotPass").hide();
        $("#AuditBy").hide();

        //绑定数据
        $.post("Member/Handlers/Member_CertifiedHandler.ashx?type=get", { CertifiedID: CertifiedID }, function (data) {
            $('#frm').fill(data);
            $("#Status").attr("value", data.Status);

            if (data.Img != "") {
                var imgs = data.Img.split("||");
                $("#Photo1").attr("src", imgs[0]);
                $("#Photo2").attr("src", imgs[1]);
            }

            if (data.Status == 0) {
                $("#AuditOpinion").prop("disabled", false);
                $("#Processing").show();
                $("#AuditNotPass").show();
                $("#AuditBy").show();
            }
            else if (data.Status == 1) {
                $("#AuditOpinion").prop("disabled", false);
                $("#AuditNotPass").show();
                $("#AuditBy").show();
            }
        }, 'json');
    }

    $(function () {
        get();

        //處理中
        $("#Processing").click(function () {
            $('#confirm .btn-primary').unbind('click');
            AuditHandle(1);
        });

        //拒 絕
        $("#AuditNotPass").click(function () {
            $('#confirm .btn-primary').unbind('click');
            if ($("#AuditOpinion").val() == "") {
                $(".alert > .content").html("审核意见不能为空！");
                $(".alert").show();
                return false;
            }
            jconfirm("你确定要拒绝此申请吗？", function () {
                AuditHandle(3);
            })
        });

        //同 意
        $("#AuditBy").click(function () {
            $('#confirm .btn-primary').unbind('click');
            jconfirm("你确定要同意此申请吗？", function () {
                AuditHandle(2);
            })
        });

        function AuditHandle(Status) {
            var AuditOpinion = $("#AuditOpinion").val();

            $.ajax({
                type: "POST",
                dataType: "json",
                url: "Member/Handlers/Member_CertifiedHandler.ashx?type=Audit",
                data: { CertifiedID: "<%= WebHelper.Get("CertifiedID") %>", AuditOpinion: AuditOpinion, Status: Status },
                success: function (data) {
                    if (data.isSuccess) {
                        loadPage("Member/Member_CertifiedList.aspx");
                    }
                    else {
                        $(".alert > .content").html(data.message);
                        $(".alert").show();
                    }
                },
                error: function (message) {
                    $(".alert > .content").html("系统异常，请稍后再试");
                    $(".alert").show();
                }
            });
        }

        $("#btnCancel").click(function () {
            loadPage("Member/Member_CertifiedList.aspx");
        });


        $(".img-thumbnail").click(function () {
            $("#img").attr("src", $(this).attr("src"));
            $("#modalImg").modal("show");
        });

    });

</script>
